#ifndef __MPU6050_REG_H
#define __MPU6050_REG_H

#define	MPU6050_SMPLRT_DIV		0x19
#define	MPU6050_CONFIG			0x1A
#define	MPU6050_GYRO_CONFIG		0x1B
#define	MPU6050_ACCEL_CONFIG	0x1C

#define	MPU6050_ACCEL_XOUT_H	0x3B
#define	MPU6050_ACCEL_XOUT_L	0x3C
#define	MPU6050_ACCEL_YOUT_H	0x3D
#define	MPU6050_ACCEL_YOUT_L	0x3E
#define	MPU6050_ACCEL_ZOUT_H	0x3F
#define	MPU6050_ACCEL_ZOUT_L	0x40
#define	MPU6050_TEMP_OUT_H		0x41
#define	MPU6050_TEMP_OUT_L		0x42
#define	MPU6050_GYRO_XOUT_H		0x43
#define	MPU6050_GYRO_XOUT_L		0x44
#define	MPU6050_GYRO_YOUT_H		0x45
#define	MPU6050_GYRO_YOUT_L		0x46
#define	MPU6050_GYRO_ZOUT_H		0x47
#define	MPU6050_GYRO_ZOUT_L		0x48

#define	MPU6050_PWR_MGMT_1		0x6B
#define	MPU6050_PWR_MGMT_2		0x6C
#define	MPU6050_WHO_AM_I		0x75

/* 当前选择的量程配置（根据实际设置修改） */
#define GYRO_FS_SELECTED     MPU6050_GYRO_FS_500DPS
#define ACCEL_FS_SELECTED    MPU6050_ACCEL_FS_4G

/* 加速度计量程配置选项 */
#define MPU6050_ACCEL_FS_2G      0x00  // ±2g
#define MPU6050_ACCEL_FS_4G      0x08  // ±4g
#define MPU6050_ACCEL_FS_8G      0x10  // ±8g
#define MPU6050_ACCEL_FS_16G     0x18  // ±16g

/* 陀螺仪量程配置选项 */
#define MPU6050_GYRO_FS_250DPS   0x00  // ±250°/s
#define MPU6050_GYRO_FS_500DPS   0x08  // ±500°/s
#define MPU6050_GYRO_FS_1000DPS  0x10  // ±1000°/s
#define MPU6050_GYRO_FS_2000DPS  0x18  // ±2000°/s

/* 重力加速度常数 (m/s²) */
#define GRAVITY_EARTH        9.80665f

/* 加速度计转换系数 (原始值转 m/s²) */
#if (ACCEL_FS_SELECTED == MPU6050_ACCEL_FS_2G)
	#define ACCEL_SCALE      (GRAVITY_EARTH / 16384.0f)  // ±2g范围: 2 / 32768
#elif (ACCEL_FS_SELECTED == MPU6050_ACCEL_FS_4G)
    #define ACCEL_SCALE      (GRAVITY_EARTH / 8192.0f)  // ±4g范围
#elif (ACCEL_FS_SELECTED == MPU6050_ACCEL_FS_8G)
    #define ACCEL_SCALE      (GRAVITY_EARTH / 4096.0f)  // ±8g范围
#elif (ACCEL_FS_SELECTED == MPU6050_ACCEL_FS_16G)
    #define ACCEL_SCALE      (GRAVITY_EARTH / 2048.0f) // ±16g范围
#endif

/* 陀螺仪转换系数 (原始值转 rad/s) */
#define PAI          3.14159265358979323846f  // π

#if (GYRO_FS_SELECTED == MPU6050_GYRO_FS_250DPS)
    #define GYRO_SCALE       ((250.0f * PAI) / (32768.0f * 180.0f))  // ±250°/s
#elif (GYRO_FS_SELECTED == MPU6050_GYRO_FS_500DPS)
    #define GYRO_SCALE       ((500.0f * PAI) / (32768.0f * 180.0f))  // ±500°/s
#elif (GYRO_FS_SELECTED == MPU6050_GYRO_FS_1000DPS)
    #define GYRO_SCALE       ((1000.0f * PAI) / (32768.0f * 180.0f)) // ±1000°/s
#elif (GYRO_FS_SELECTED == MPU6050_GYRO_FS_2000DPS)
    #define GYRO_SCALE       ((2000.0f * PAI) / (32768.0f * 180.0f)) // ±2000°/s
#endif

#endif
